package com.treasure.mall.zbqmallapi.vo.live;

import com.treasure.mall.biz.dto.live.SessionStatisticsDTO;
import com.treasure.mall.biz.entity.live.LiveSessionPO;
import com.treasure.mall.biz.service.core.live.LiveSessionService;
import com.treasure.mall.biz.vo.BaseVO;
import com.treasure.mall.zbq.common.ienum.live.LiveEnums;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 *
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.vo.live
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/14 12:05
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.zbqmallapi.vo.live Inc. All rights reserved.
 */
@Data
@NoArgsConstructor
public class LiveSessionVO implements BaseVO {
    private static final long serialVersionUID = -451916524026064036L;
    private String id;
    /**
     * 播放地址
     */
    private String playUrl;

    /**
     * 直播状态
     */
    private LiveEnums.PlayStatus playStatus;
    /**
     * 直播统计
     */
    private SessionStatisticsDTO statisticsData;
    /**
     * 开始时间
     */
    private LocalDateTime startTime;
    /**
     * 结束时间
     */
    private LocalDateTime endTime;
    /**
     * 预告时间
     */
    private LocalDateTime foreshowTime;
    /**
     * 预告内容
     */
    private String foreshowDesc;

    public LiveSessionVO(LiveSessionPO liveSessionPO, LiveSessionService liveSessionService) {
        this.id = liveSessionPO.getId();
        this.playUrl = liveSessionPO.getPlayUrl();
        this.playStatus = liveSessionPO.getPlayStatus();
        if (playStatus == LiveEnums.PlayStatus.PAYING) {
            this.statisticsData = liveSessionService.getStatistics(this.id);
        } else {
            this.statisticsData = new SessionStatisticsDTO(liveSessionPO);
        }
        this.startTime = liveSessionPO.getStartTime();
        this.endTime = liveSessionPO.getEndTime();
        this.foreshowTime = liveSessionPO.getForeshowTime();
        this.foreshowDesc = liveSessionPO.getForeshowDesc();
    }
}
